﻿using AutoMapper;
using MediatR;
using SupplyChain.Domain.Entities;
using SupplyChain.Infrastructure.Interface;
using SupplyChain.Write.API.Application.Command.Supplier;

namespace SupplyChain.Write.API.Application.CommandHandler.Supplier
{
    public class GetSupplierCategoryHandler : IRequestHandler<GetSupplierCategoryCommand, List<SupplierCategory>>
    {
        private readonly IBaseRepository<SupplierCategory> repository;
        private readonly IMapper mapper;

        public GetSupplierCategoryHandler(IBaseRepository<SupplierCategory> repository, IMapper mapper)
        {
            this.repository = repository;
            this.mapper = mapper;
        }

        public async Task<List<SupplierCategory>> Handle(GetSupplierCategoryCommand request, CancellationToken cancellationToken)
        {
            return await Task.FromResult(await repository.GetByWhereAsync(x => !x.IsDel));
        }
    }
}
